/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cse308.entities;

import cse308.GeneralEntity;
import cse308.helper_classes.GeneralTest;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Aaron
 */
@Entity
@Table(catalog = "nchorn", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Courseoutcome.findAll", query = "SELECT c FROM Courseoutcome c"),
    @NamedQuery(name = "Courseoutcome.findByIdentifier", query = "SELECT c FROM Courseoutcome c WHERE c.identifier = :identifier"),
    @NamedQuery(name = "Courseoutcome.findBySeqNum", query = "SELECT c FROM Courseoutcome c WHERE c.seqNum = :seqNum"),
    @NamedQuery(name = "Courseoutcome.findByDescription", query = "SELECT c FROM Courseoutcome c WHERE c.description = :description"),
    @NamedQuery(name = "Courseoutcome.findByRationale", query = "SELECT c FROM Courseoutcome c WHERE c.rationale = :rationale"),
    @NamedQuery(name = "Courseoutcome.findByAssessed", query = "SELECT c FROM Courseoutcome c WHERE c.assessed = :assessed")})
public class Courseoutcome implements Serializable, GeneralEntity {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(nullable = false, length = 20)
    private String identifier;
    private Integer seqNum;
    @Size(max = 120)
    @Column(length = 120)
    private String description;
    @Size(max = 120)
    @Column(length = 120)
    private String rationale;
    private Boolean assessed;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "courseoutcome")
    private Collection<Courseoutcomedirectassessment> courseoutcomedirectassessmentCollection;
    @OneToMany(mappedBy = "courseoutcomeIdentifier")
    private Collection<Courseoutcomesurveyresults> courseoutcomesurveyresultsCollection;
    @JoinColumn(name = "studentoutcome", referencedColumnName = "identifier")
    @ManyToOne
    private Studentoutcome studentoutcome;
    @JoinColumn(name = "courseidentifier", referencedColumnName = "identifier")
    @ManyToOne
    private Courseinfo courseidentifier;
  
    public Courseoutcome() {
        this.courseoutcomedirectassessmentCollection = new ArrayList();
        this.courseoutcomesurveyresultsCollection = new ArrayList();
    }

    public Courseoutcome(String identifier) {
        this.identifier = identifier;
        this.courseoutcomedirectassessmentCollection = new ArrayList();
        this.courseoutcomesurveyresultsCollection = new ArrayList();
    }

    public String getIdentifier() {
        return identifier;
    }

    public void setIdentifier(String identifier) {
        this.identifier = identifier;
    }

    public Integer getSeqNum() {
        return seqNum;
    }

    public void setSeqNum(Integer seqNum) {
        this.seqNum = seqNum;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getRationale() {
        return rationale;
    }

    public void setRationale(String rationale) {
        this.rationale = rationale;
    }

    public Boolean getAssessed() {
        return assessed;
    }

    public void setAssessed(Boolean assessed) {
        this.assessed = assessed;
    }

    @XmlTransient
    public Collection<Courseoutcomedirectassessment> getCourseoutcomedirectassessmentCollection() {
        return courseoutcomedirectassessmentCollection;
    }

    public void setCourseoutcomedirectassessmentCollection(Collection<Courseoutcomedirectassessment> courseoutcomedirectassessmentCollection) {
        this.courseoutcomedirectassessmentCollection = courseoutcomedirectassessmentCollection;
    }

    @XmlTransient
    public Collection<Courseoutcomesurveyresults> getCourseoutcomesurveyresultsCollection() {
        return courseoutcomesurveyresultsCollection;
    }

    public void setCourseoutcomesurveyresultsCollection(Collection<Courseoutcomesurveyresults> courseoutcomesurveyresultsCollection) {
        this.courseoutcomesurveyresultsCollection = courseoutcomesurveyresultsCollection;
    }

    public Studentoutcome getStudentoutcome() {
        return studentoutcome;
    }

    public void setStudentoutcome(Studentoutcome studentoutcome) {
        this.studentoutcome = studentoutcome;
    }

    public Courseinfo getCourseidentifier() {
        return courseidentifier;
    }

    public void setCourseidentifier(Courseinfo courseidentifier) {
        this.courseidentifier = courseidentifier;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (identifier != null ? identifier.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Courseoutcome)) {
            return false;
        }
        Courseoutcome other = (Courseoutcome) object;
        if ((this.identifier == null && other.identifier != null) || (this.identifier != null && !this.identifier.equals(other.identifier))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cse308.entities.Courseoutcome[ identifier=" + identifier + " ]";
    }
    @Override
    public List<GeneralEntity> getAssociatedClass(String associated) {
        List<GeneralEntity> toReturn = new ArrayList();
        if (associated.equals(Studentoutcome.class.getSimpleName())) {
            toReturn.add(this.studentoutcome);
        } else if (associated.equals(Courseinfo.class.getSimpleName())) {
            toReturn.add(this.courseidentifier);
        }
        return toReturn;
    }

    @Override
    public void setWithClass(GeneralTest gt) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void testAddClass(GeneralEntity ge) {
        if (ge instanceof Studentoutcome) {
            this.studentoutcome = (Studentoutcome) ge;
        } else if (ge instanceof Courseinfo) {
            this.courseidentifier = (Courseinfo) ge;
        }
    }

    @Override
    public void removeClass(GeneralEntity ge) {
        if (ge instanceof Studentoutcome) {
            this.studentoutcome = null;
        } else if (ge instanceof Courseinfo) {
            this.courseidentifier = null;
        }
    }

    @Override
    public GeneralEntity findCorrespondingEntity() {
        return this;
    }

    @Override
    public String getIdentifier2() {
        return this.identifier;
    }

    @Override
    public boolean equalsEntity(GeneralEntity entity) {
        return this.equals(entity);
    }

    @Override
    public List<List<GeneralEntity>> getAssociatedClasses() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public Object getPK() {
        return this.identifier;
    }
 
}
